package edu.java.homework.hw04.classes;

/**
 * Implement a 2D Point
 * 
 * @author Tsvetan Vasilev
 * 
 */
public class Point2D {

    // --- Instance Variables --------------------------------------------------
    private double coordX = 0.0d;
    private double coordY = 0.0d;

    // --- Constructors
    // ---------------------------------------------------------

    public Point2D() {
	coordX = 0.0d;
	coordY = 0.0d;
    }

    public Point2D(double coordX, double coordY) {
	this.coordX = coordX;
	this.coordY = coordY;
    }

    public Point2D(Point2D point) {
	coordX = point.getCoordX();
	coordY = point.getCoordY();
    }

    // --- Setters and Getters
    // --------------------------------------------------
    public double getCoordX() {
	return coordX;
    }

    public void setCoordX(double coordX) {
	this.coordX = coordX;
    }

    public double getCoordY() {
	return coordY;
    }

    public void setCoordY(double coordY) {
	this.coordY = coordY;
    }

    // --- Methods -------------------------------------------------------------

    @Override
    public String toString() {
	String result = "(" + getCoordX() + ", " + getCoordY() + ")";
	return result;
    }

    @Override
    public boolean equals(Object obj) {
	if (obj == null) {
	    return false;
	}

	if (!(obj instanceof Point2D)) {
	    return false;
	}

	Point2D point = (Point2D) obj;
	// if (
	return (this.getCoordX() == point.getCoordX())
		&& (this.getCoordY() == point.getCoordY());
	// ) {
	// return true;
	// }else{
	// return false;
	// }

    }

}
